<?php
/**
 * Description of resultset
 *
 * @author tridungpham
 */
class ResultSet
{
    private $_rows = array();

    function  __construct($dbResult = NULL)
    {
        if (!is_null($dbResult))
        {
            $this->analyzeData($dbResult);
        }
    }

    private function analyzeData($dbResult)
    {
        if($dbResult)
        {
            while ($row = mysql_fetch_array($dbResult))
            {
                $obj = new DataObject($row);
                $this->_rows[] = $obj;
            }
        }
    }

    public function setData($dbResult)
    {
        $this->analyzeData($dbResult);
    }

    public function getRow($rowIndex)
    {
        if ($rowIndex < 0 || $rowIndex > count($this->_rows))
        {
            exit('Array out of index');
        }
        return $this->_rows[$rowIndex];
    }

    public function getAll()
    {
        return $this->_rows;
    }

    public function getSize()
    {
        return count($this->_rows);
    }
}

?>
